package jupitermouse.site.juc.demo.aqs.condition;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

/**
 * <p>
 * </p>
 *
 * @author jupiter
 */
public class ConditionNotify implements Runnable{
    private Lock lock;
    private Condition condition;

    public ConditionNotify(Lock lock, Condition condition) {
        this.lock = lock;
        this.condition = condition;
    }

    @Override
    public void run() {
        try{
            lock.lock();
            System.out.println("begin - conditionNotify - 唤醒开始");
            condition.signal(); //唤醒阻塞状态的线程
            System.out.println("begin - conditionSignal - 唤醒");
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }

    }
}
